{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 写出导入numpy的语句，并且给numpy别名为np。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 创建一个变量名为`arr1`的一维数组，里面的元素为整数6、2、-7、2、8、-2、1。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 6,  2, -7,  2,  8, -2,  1])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1 = np.array([6,2,-7,2,8,-2,1])\n",
    "arr1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 创建一个变量名为`arr2`的二维数组，里面的元素为以下两个数组：由整数1、3、5组成的一维数组，以及由整数2、4、6组成的一维数组。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 3, 5],\n",
       "       [2, 4, 6]])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr2 = np.array([[1,3,5],[2,4,6]])\n",
    "arr2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 分别打印`arr1`和`arr2`的维度、形状、元素数量、元素类型。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "arr1 的信息：\n",
      "数组内容: [ 6  2 -7  2  8 -2  1]\n",
      "维度 (ndim): 1\n",
      "形状 (shape): (7,)\n",
      "元素数量 (size): 7\n",
      "元素类型 (dtype): int64\n",
      "\n",
      "arr2 的信息：\n",
      "数组内容: [[1 3 5]\n",
      " [2 4 6]]\n",
      "维度 (ndim): 2\n",
      "形状 (shape): (2, 3)\n",
      "元素数量 (size): 6\n",
      "元素类型 (dtype): int64\n"
     ]
    }
   ],
   "source": [
    "print(\"arr1 的信息：\")\n",
    "print(\"数组内容:\", arr1)\n",
    "print(\"维度 (ndim):\", arr1.ndim)  ##表示的是一维还是二维\n",
    "print(\"形状 (shape):\", arr1.shape)##表示有几行几列\n",
    "print(\"元素数量 (size):\", arr1.size)\n",
    "print(\"元素类型 (dtype):\", arr1.dtype)\n",
    "print()\n",
    "\n",
    "print(\"arr2 的信息：\")\n",
    "print(\"数组内容:\", arr2)\n",
    "print(\"维度 (ndim):\", arr2.ndim)\n",
    "print(\"形状 (shape):\", arr2.shape)\n",
    "print(\"元素数量 (size):\", arr2.size)\n",
    "print(\"元素类型 (dtype):\", arr2.dtype)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 创建一个变量名为`arr_all_0`的一维数组，里面的元素为6个0。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0., 0., 0., 0., 0., 0.])"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr_all_0 = np.zeros(6)\n",
    "arr_all_0"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 创建一个变量名为`arr_all_1`的一维数组，里面的元素为6个1。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "arr_all_1 = np.ones(6)\n",
    "arr_all_1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 创建一个变量名为`arr_even`的一维数组，里面的元素为10（包括10）到20（包括20）之间的偶数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([10, 12, 14, 16, 18, 20])"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr_even = np.arange(10,21,2)\n",
    "arr_even"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
